import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2

Rectangle {
    color:"#121212"

    //入管警戒温度设置
    Slider{
        id: tubeInSlid
        maximumValue: 1500
        minimumValue: 600
        value: mainwin.aler_tube_in_temp
        width: 450
        height: 20
        stepSize : 1
        anchors.horizontalCenter: parent.horizontalCenter
        y:250
        onValueChanged: {
            tubeInSpin.value=value
        }

        style: SliderStyle {
            groove: Rectangle {
                implicitWidth: 450
                implicitHeight: 20
                color: "#444444"
                radius: implicitHeight/2
                Rectangle{
                                width: styleData.handlePosition
                                height: 20
                                radius: height/2
                                color: "#4578aa"
                            }
            }
            handle: Rectangle {
                anchors.centerIn: parent
                color: control.pressed ? "white" : "lightgray"
                border.color: "gray"
//                border.width: 2
                implicitWidth: 35
                implicitHeight: 25
                radius: implicitHeight/2
            }
        }

    }

    SpinBox{
        id:tubeInSpin
        maximumValue: tubeInSlid.maximumValue
        minimumValue: tubeInSlid.minimumValue
        stepSize: 1
        value: mainwin.aler_tube_in_temp
        anchors.left: tubeInSlid.right
        anchors.leftMargin: 30
        anchors.verticalCenter: tubeInSlid.verticalCenter
        width:100
        height:25
        suffix : "℃"
        font.pixelSize: 20
//        inputMethodComposing : true
        onValueChanged: {
            tubeInSlid.value=value
        }
    }

    Label{
        id:tubeInText
        anchors.right: tubeInSlid.left
        anchors.rightMargin: 20
        anchors.verticalCenter: tubeInSlid.verticalCenter
        text: "入管警戒温度设置"
        color:"#4578dd"
        font.pixelSize: 22
    }

    //出管警戒温度设置
    Slider{
        id: tubeOutSlid
        maximumValue: 1500
        minimumValue: 600
        value: mainwin.aler_tube_out_temp
        width: 450
        height: 20
        stepSize : 1
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: tubeInSlid.bottom
        anchors.topMargin: 45
//        tickmarksEnabled : true
        onValueChanged: {
            tubeOutSpin.value=value
        }

        style: SliderStyle {
            groove: Rectangle {
                implicitWidth: 450
                implicitHeight: 20
                color: "#444444"
                radius: implicitHeight/2
                Rectangle{
                                width: styleData.handlePosition
                                height: 20
                                radius: height/2
                                color: "#4578aa"
                            }
            }
            handle: Rectangle {
                anchors.centerIn: parent
                color: control.pressed ? "white" : "lightgray"
                border.color: "gray"
//                border.width: 2
                implicitWidth: 35
                implicitHeight: 25
                radius: implicitHeight/2
            }
        }

    }

    SpinBox{
        id:tubeOutSpin
        maximumValue: tubeOutSlid.maximumValue
        minimumValue: tubeOutSlid.minimumValue
        stepSize: 1
        value: mainwin.aler_tube_out_temp
        anchors.left: tubeOutSlid.right
        anchors.leftMargin: 30
        anchors.verticalCenter: tubeOutSlid.verticalCenter
        width:100
        height:25
        suffix : "℃"
        font.pixelSize: 20
//        inputMethodComposing : true
        onValueChanged: {
            tubeOutSlid.value=value
        }
    }

    Label{
        id:tubeOutText
        anchors.right: tubeOutSlid.left
        anchors.rightMargin: 20
        anchors.verticalCenter: tubeOutSlid.verticalCenter
        text: "出管警戒温度设置"
        color:"#4578dd"
        font.pixelSize: 22
    }

    //COT警戒温度设置

    Slider{
        id: tubeCOTSlid
        maximumValue: 1500
        minimumValue: 600
        value: mainwin.aler_tube_cot_temp
        width: 450
        height: 20
        stepSize : 1
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: tubeOutSlid.bottom
        anchors.topMargin: 45
//        tickmarksEnabled : true
        onValueChanged: {
            tubeCOTSpin.value=value
        }

        style: SliderStyle {
            groove: Rectangle {
                implicitWidth: 450
                implicitHeight: 20
                color: "#444444"
                radius: implicitHeight/2
                Rectangle{
                                width: styleData.handlePosition
                                height: 20
                                radius: height/2
                                color: "#4578aa"
                            }
            }
            handle: Rectangle {
                anchors.centerIn: parent
                color: control.pressed ? "white" : "lightgray"
                border.color: "gray"
//                border.width: 2
                implicitWidth: 35
                implicitHeight: 25
                radius: implicitHeight/2
            }
        }

    }

    SpinBox{
        id:tubeCOTSpin
        maximumValue: tubeCOTSlid.maximumValue
        minimumValue: tubeCOTSlid.minimumValue
        stepSize: 1
        value: mainwin.aler_tube_cot_temp
        anchors.left: tubeCOTSlid.right
        anchors.leftMargin: 30
        anchors.verticalCenter: tubeCOTSlid.verticalCenter
        width:100
        height:25
        suffix : "℃"
        font.pixelSize: 20
//        inputMethodComposing : true
        onValueChanged: {
            tubeCOTSlid.value=value
        }
    }

    Label{
        id:tubeCOTText
        anchors.right: tubeCOTSlid.left
        anchors.rightMargin: 20
        anchors.verticalCenter: tubeCOTSlid.verticalCenter
        text: "COT警戒温度设置"
        color:"#4578dd"
        font.pixelSize: 22
    }

    //组间温度差警戒线设置
    Slider{
        id: tempGapSlid
        maximumValue: 30
        minimumValue: 5
        value: mainwin.aler_gap_temp

        width: 450
        height: 20
        stepSize : 1
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: tubeCOTSlid.bottom
        anchors.topMargin: 45
//        tickmarksEnabled : true
        onValueChanged: {
            tempGapSpin.value=value
        }

        style: SliderStyle {
            groove: Rectangle {
                implicitWidth: 450
                implicitHeight: 20
                color: "#444444"
                radius: implicitHeight/2
                Rectangle{
                                width: styleData.handlePosition
                                height: 20
                                radius: height/2
                                color: "#4578aa"
                            }
            }
            handle: Rectangle {
                anchors.centerIn: parent
                color: control.pressed ? "white" : "lightgray"
                border.color: "gray"
//                border.width: 2
                implicitWidth: 35
                implicitHeight: 25
                radius: implicitHeight/2
            }
        }

    }

    SpinBox{
        id:tempGapSpin
        maximumValue: tempGapSlid.maximumValue
        minimumValue: tempGapSlid.minimumValue
        stepSize: 1
        value: mainwin.aler_gap_temp
        anchors.left: tempGapSlid.right
        anchors.leftMargin: 30
        anchors.verticalCenter: tempGapSlid.verticalCenter
        width:100
        height:25
        suffix : "℃"
        font.pixelSize: 20
//        inputMethodComposing : true
        onValueChanged: {
            tempGapSlid.value=value
        }
    }

    Label{
        id:tempGapText
        anchors.right: tempGapSlid.left
        anchors.rightMargin: 20
        anchors.verticalCenter: tempGapSlid.verticalCenter
        text: "同组炉管温度差警戒线设置"
        color:"#4578dd"
        font.pixelSize: 22
    }

    //确定按钮
    Rectangle{
        id:comfirmBnt
        color: ma.containsMouse?"#2f2f2f":"#202020"
        radius: 3
        width: 250
        height: 60
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: tempGapText.bottom
        anchors.topMargin: 100
        border.width: 1
        scale: ma.containsMouse?1:0.8
        Behavior on scale{
            PropertyAnimation{
                properties: "scale"
                duration: 350
                easing.type: Easing.OutQuint
            }
        }
        Behavior on color{
            PropertyAnimation{
                properties: "color"
                duration: 350
                easing.type: Easing.OutQuint
            }
        }

        border.color: "#404040"
        Text {
            id: bntText
            text: qsTr("确定修改")
            font.pixelSize: 35
            color: "#12aadf"
            font.bold: true
            style: Text.Outline
            styleColor: "#454545"
            anchors.centerIn: parent
        }
        MouseArea{
            anchors.fill: parent
            id:ma
            hoverEnabled: true
            onClicked: {
                server.set_aler_temps_value(tubeInSlid.value,tubeOutSlid.value,tubeCOTSlid.value,tempGapSlid.value)
                mainwin.aler_tube_in_temp=server.get_aler_temps_value(0)
                mainwin.aler_tube_out_temp=server.get_aler_temps_value(1)
                mainwin.aler_tube_cot_temp=server.get_aler_temps_value(2)
                mainwin.aler_gap_temp=server.get_aler_temps_value(3)
                ptimer.start();
            }
        }
    }
    Text{
        id:tip
        text:"设置成功"
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 60
        font.pixelSize: 45
        font.bold: true
        color:"#12aaef"
//        opacity: 0
        scale:0
        Behavior on scale {
            PropertyAnimation{
                properties: "scale"
                duration: 450
                easing.type: Easing.OutBack
            }
        }
    }
    Timer{
        id:ptimer
        interval: 500
        repeat: true
        onTriggered: {
            if(tip.scale===0){
                tip.scale=1
                interval=5000;
            }
            else{
                tip.scale=0
                interval=500
                stop();
            }
        }
    }

}
